<?php

namespace app\common\model;

use basic\ModelBasic;

class RoutesDetails extends ModelBasic
{
	use \traits\ModelTrait;

	public static function syncArticles(array $articles)
	{
		$cachedSyncArticle = \think\Cache::get(\service\XiumiEditorService::SYNC_ARTICL_KEY);
        if ( empty($cachedSyncArticle) ) return false;

        $route_id = $cachedSyncArticle->route_id ?? 0;
        if ( empty($route_id) ) return false;

        $article = $articles[0] ?? [];
        if ( empty($article) ) return false;

        $cachedSyncArticle->mod_details = $article['description'];
        $cachedSyncArticle->article_id  = $article['article_id'];
        $res = $cachedSyncArticle->save();
        if ( $res === false ) return false;

        \think\Cache::set(\service\XiumiEditorService::SYNC_ARTICL_KEY , null);
		return true;
	}
}//Class End
